package com.wd.car.vm

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.wd.common.base.BaseViewModel
import com.wd.common.bean.UserInfo
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers

/**
 * 作者：马海钊
 * 时间：2024/5/26 20:27
 * 功能：
 */
class LoginViewmodel :BaseViewModel(){
    //微信登录
    val userinfo: MutableLiveData<UserInfo> = MutableLiveData()
    fun wxLogin(code:String){
        api?.let {
            it.wxlogin(code)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe({bean->
                    userinfo.value=bean.result!!
                },{error->
                    Log.e("wxlogin",error.message.toString())
                })
        }
    }
}